package cn.iocoder.yudao.module.api.trade.order.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumCodable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 交易订单 - 状态
 *
 * @author Sin
 */
@Getter
@AllArgsConstructor
public enum TradeOrderStatusCodeEnum implements EnumCodable {

    ALL("all", "全部"),
    PAYMENT("payment", "待付款"),
    PAID("paid", "已付款"),
    RIDER("deliver", "待配送"),
    DELIVERY("delivery", "待发货"),
    ONSITE("onsite", "待服务"),
    DOING("doing", "进行中"),
    ARRIVING("arriving", "配送中"),
    RECEIVE("receive", "待收货"),
    CLERK("clerk", "待核销"),
    COMPLETE("complete", "已完成"),
    COMMENT("comment", "待评价"),
    CLOSED("toggle", "已关闭"),
    REFUND("return", "售后退款"),
    ;

    @EnumValue
    private final String code;
    private final String name;

    public static TradeOrderStatusCodeEnum codeOf(String code) {
        return Stream.of(values())
                .filter(p -> Objects.equals(p.code, code))
                .findAny()
                .orElse(ALL);
    }

}
